package com.zgw.his.emr.workbench.action;

import java.io.IOException;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;

import com.zgw.his.emr.resource.RecordResourceManager;
import com.zgw.his.emr.workbench.DefaultContainer;
import com.zgw.his.emr.workbench.NavigationView;

public class SaveAction extends Action {
	public static final String ID = "com.zgw.his.emr.workbench.action.SaveAction";

	public SaveAction() {
		super("保存");
		setId(ID);
	}

	@Override
	public void run() {
		DefaultContainer cont = NavigationView.container;
		cont.getCurrentPage();
		cont.getCurrentPage().refresh_record();
		try {
			RecordResourceManager.saveRecordToFile(cont.getRecord());
		} catch (IOException e) {
			MessageDialog.openError(Display.getCurrent().getActiveShell(),
					"错误信息", "保存失败:" + e.getMessage());
			e.printStackTrace();
		}
	}
}
